package com.gamificationlibrary.adapter;

import java.util.ArrayList;

import com.gamificationlibrary.gamificationlibrary.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class SpinnerColorAdapter extends ArrayAdapter<String> {

       private ArrayList<String> mStrings;
       private int[] mColor;


       public SpinnerColorAdapter(Context ctx, ArrayList<String> strings, int[] colors) 
       {
           super(ctx, android.R.layout.simple_spinner_dropdown_item, strings);
           mStrings = strings;
           mColor=colors;
       }
       
           
      	 @Override
           public View getView(int position, View convertView, ViewGroup parent){
                View v = convertView;
                if (v == null) {
                   Context mContext = this.getContext();
                   LayoutInflater vi = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                v = vi.inflate(R.layout.spinner_item, null);
                }
	
		        TextView tv = (TextView) v.findViewById(R.id.textView_spinnerItem);
		        tv.setText(mStrings.get(position));
		        tv.setTextColor(mColor[position]);  
	        
	            return v;  
	         }   
      	 
      	 
          @Override
           public View getDropDownView(int position, View convertView, ViewGroup parent){
                View v = convertView;
                if (v == null) {
                   Context mContext = this.getContext();
                   LayoutInflater vi = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                v = vi.inflate(R.layout.spinner_item, null);
                }
		
		        TextView tv = (TextView) v.findViewById(R.id.textView_spinnerItem);
		        tv.setText(mStrings.get(position));
		        tv.setTextColor(mColor[position]); 
		            return v;  
          		}              
 }
